#ifndef _GRO_SPINNER_H__
#define _GRO_SPINNER_H__

#include "GRO_Button.h"
#include "GRO_Text.h"

namespace GRO
{

class Spinner : public Widget
{
public:

    int* linkedValue;
    int min;
    int value;
    int max;

    int increment;

    Button plus;
    Button minus;
    Button* clicked;  // keep my own clicking state
    
    DirectionEnum direction;
    
    Uint32 repeatDelay;
    Uint32 repeatStart;
    Uint32 repeatInitDelay;
    Uint32 repeatLast;
    bool repeating;
    

    Spinner();
    Spinner(const Dimensions& dims);
    Spinner(const Dimensions& dims, int initValue, int Min, int Max, const Dimensions& buttonDims, DirectionEnum Direction);
    
    
    void increase();
    void decrease();
    
    void refreshTextOnClick(Text* text);
    
    virtual void connectBeacon(Widget* widget, Beacon* beacon, const std::string& fn_name, const std::vector<std::string>& args);
    
    /*virtual void applyTheme(Theme* theme, bool recursive = 0);*/
    

    virtual void setGui(Gui* Gui);
    virtual void setGroup(Group* Group);
    virtual void setPanel(Panel* Panel);

    virtual void link(int* Value);

    virtual void draw(SDL_Rect* clipRect);

    virtual void setValue(int Value);

    virtual int getValue();

    // Has actually been clicked
    virtual Widget* findWidget(int mx, int my);
    virtual Widget* action(PointerCursor* mouse, ActionEnum actionType);
    
    virtual Widget* action(NavCursor* nav, ActionEnum actionType);


    virtual void update();
    virtual TiXmlElement* save(TiXmlElement* parent);
    virtual bool load(TiXmlElement* w);
};

}

#endif
